﻿
# load an assembly from the samples bin directory
require 'bin\Eswat.Samples.SampleComponentLibrary.dll'

# import test types
include Eswat::Samples::SampleComponentLibrary
include Eswat::Services::WebDriver

# alias test services
$verify = $eswat_test.Services.Verify
$web = $eswat_test.Services.WebDriver

# test a sample .NET component
$comp = SampleComponent.new
$comp.Title = "hello component world!"
$verify.AreEqual("hello component world!", $comp.Title, "sample component title should match")

# -------------------------------------------------------------
# test WebDriver test service
# -------------------------------------------------------------

$web.Open(WebBrowserType.IE)

$nav = $web.Navigate()

$nav.GoToUrl("http://localhost:61614/Auth/SignOut")

$verify.AreEqual("Mileage Stats | Know where your gas takes you", $web.Title, "Silk landing page title should match")

$web.Quit()

# -------------------------------------------------------------
# test NUnit test service
# -------------------------------------------------------------

$verify.True(TRUE)
$verify.True(TRUE, "True(TRUE) should succeed")
$verify.True(TRUE, "True({0}) should succeed", "True")
$verify.True(FALSE, "True(FALSE) should fail")

$verify.IsTrue(TRUE)
$verify.IsTrue(TRUE, "IsTrue(TRUE) should succeed")
$verify.IsTrue(TRUE, "IsTrue({0}) should succeed", "True")
$verify.IsTrue(FALSE, "IsTrue(FALSE) should fail")

$verify.False(FALSE)
$verify.False(FALSE, "False(FALSE) should succeed")
$verify.False(FALSE, "False({0}) should succeed", "FALSE")
$verify.False(TRUE, "False(TRUE) should fail")

$verify.IsFalse(FALSE)
$verify.IsFalse(FALSE, "IsFalse(FALSE) should succeed")
$verify.IsFalse(FALSE, "IsFalse({0}) should succeed", "FALSE")
$verify.IsFalse(TRUE, "IsFalse(TRUE) should fail")

# bool
$verify.AreEqual(TRUE, TRUE)
$verify.AreEqual(TRUE, TRUE, "AreEqual(TRUE, TRUE) should succeed")
$verify.AreEqual(TRUE, TRUE, "AreEqual({0}) should succeed", "TRUE, TRUE")
$verify.AreEqual(TRUE, FALSE, "AreEqual(TRUE, FALSE) should fail")

# float -> passed to .NET as Double
$verify.AreEqual(0.0, 0.0)
$verify.AreEqual(0.0, 0.0, "AreEqual(0.0, 0.0) should succeed")
$verify.AreEqual(0.0, 0.0, "AreEqual({0}) should succeed", "0.0, 0.0")
$verify.AreEqual(0.0, 0.1, "AreEqual(0.0, 0.1) should fail")

nil